<?php

/**
 * Traitement form base class.
 *
 * @method Traitement getObject() Returns the current form's model object
 *
 * @package    appcemhti
 * @subpackage form
 * @author     Steve Cancès
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseTraitementForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_traitement'         => new sfWidgetFormInputHidden(),
      'id_type_traitement'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TypeTraitement'), 'add_empty' => false)),
      'id_lot'                => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Lot'), 'add_empty' => true)),
      'id_echantillon'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Echantillon'), 'add_empty' => true)),
      'id_lieu'               => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Lieu'), 'add_empty' => true)),
      'id_mesure'             => new sfWidgetFormInputText(),
      'ok'                    => new sfWidgetFormInputText(),
      'numero_fiche_machine'  => new sfWidgetFormInputText(),
      'date_debut_traitement' => new sfWidgetFormDateTime(),
      'duree_traitement'      => new sfWidgetFormInputText(),
      'repertoire'            => new sfWidgetFormInputText(),
      'ordre'                 => new sfWidgetFormInputText(),
      'created_at'            => new sfWidgetFormDateTime(),
      'updated_at'            => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id_traitement'         => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_traitement')), 'empty_value' => $this->getObject()->get('id_traitement'), 'required' => false)),
      'id_type_traitement'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TypeTraitement'))),
      'id_lot'                => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Lot'), 'required' => false)),
      'id_echantillon'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Echantillon'), 'required' => false)),
      'id_lieu'               => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Lieu'), 'required' => false)),
      'id_mesure'             => new sfValidatorInteger(array('required' => false)),
      'ok'                    => new sfValidatorInteger(array('required' => false)),
      'numero_fiche_machine'  => new sfValidatorString(array('max_length' => 32, 'required' => false)),
      'date_debut_traitement' => new sfValidatorDateTime(array('required' => false)),
      'duree_traitement'      => new sfValidatorInteger(array('required' => false)),
      'repertoire'            => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'ordre'                 => new sfValidatorInteger(array('required' => false)),
      'created_at'            => new sfValidatorDateTime(array('required' => false)),
      'updated_at'            => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('traitement[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Traitement';
  }

}
